//
//  ReportVC.swift
//  mmda
//
//  Created by 李陆涛 on 2018/8/17.
//  Copyright © 2018年 mmda. All rights reserved.
//

import UIKit

class ReportVC: BaseTabVC {

    var bid:Int?
    
    override func viewDidLoad() {
        super.viewDidLoad()

       setupUI()
    }

    private func setupUI() {
    
        self.tableView.rowHeight = 44
        self.tableView.sectionHeaderHeight = 40
        self.tableView.tableFooterView = UIView()
        self.tableView.backgroundColor = UIColor.groupTableViewBackground
        
        self.title = "投诉"
    }

}

extension ReportVC {
    
    
    override func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
        
        
        let view = UIView()
        view.backgroundColor = UIColor.groupTableViewBackground
        
        let label = UILabel(frame: CGRect(x: 16, y: 0, width: kScreenWidth - 32, height: 40))
        label.font = kFont14
         label.text = "请选择投诉的原因："
        
        view.addSubview(label)
        
        return view
    }
    
    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        
        return AppManager.share.appModel?.app_complaints?.count ?? 0
    }
    
    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        
        var cell = tableView.dequeueReusableCell(withIdentifier: "cell")
        
        if cell == nil {
            
            cell = UITableViewCell(style: .default, reuseIdentifier: "cell")
            
            cell?.textLabel?.font = kFont14
            cell?.textLabel?.textColor = UIColor.darkGray
        }
        
        let complaint = AppManager.share.appModel?.app_complaints?[indexPath.row]
        
        cell?.textLabel?.text = complaint?.value
        
        return cell!
    }
    
    
    override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        
        tableView.deselectRow(at: indexPath, animated: true)
        
        let complaint = AppManager.share.appModel?.app_complaints?[indexPath.row]
        
        let fbVC = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "FeedbackVC") as! FeedbackVC
        
        fbVC.key = complaint?.key
        fbVC.bid = bid
        fbVC.pageType = 1
        
        self.show(fbVC, sender: nil)
    }
    
}
